package com.sicheng.蓝桥.练习题;

import java.util.Scanner;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/1/17 23:08
 */
public class 拿金币 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] nums = new int[n][n];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                nums[i][j] = scanner.nextInt();
            }
        }

        int[][] dp = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + nums[i - 1][j - 1];
            }
        }

        System.out.println(dp[n][n]);

    }
}
